{include file="public/_header" /}
<style>
    #mainForm {
        max-width: 1000px;
        margin: 30px auto;
    }

    #mainForm .layui-form-item {
        margin-bottom: 25px;
    }

    .layui-form-label {
        width: 100px;
    }
    .layui-input-block {
        margin-left: 150px;
    }

</style>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header">{:dictionary('add')}</div>
        <div class="layui-card-body">
            <form class="layui-form" id="mainForm">
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">{:dictionary('dictionary.title')}:</label>
                    <div class="layui-input-block">
                        <input name="title" id="title" placeholder="请输入" class="layui-input"
                               lay-verType="tips" />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">{:dictionary('dictionary.type')}:</label>
                    <div class="layui-input-block">
                        <input name="type" id="type" placeholder="请输入" class="layui-input" />
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">{:dictionary('dictionary.value')}:</label>
                    <div class="layui-input-block">
                        <input name="value" id="value" placeholder="请输入" class="layui-input" />
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">{:dictionary('dictionary.value_en')}:</label>
                    <div class="layui-input-block">
                        <input name="value_en" id="value_en" placeholder="请输入" class="layui-input" />
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">{:dictionary('dictionary.value_jp')}:</label>
                    <div class="layui-input-block">
                        <input name="value_jp" id="value_jp" placeholder="请输入" class="layui-input" />
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">{:dictionary('dictionary.value_kr')}:</label>
                    <div class="layui-input-block">
                        <input name="value_kr" id="value_kr" placeholder="请输入" class="layui-input" />
                    </div>
                </div>

                <div class="form-group-bottom text-right">
                    <button type="reset" class="layui-btn layui-btn-primary">&emsp;{:dictionary('reset')}&emsp;</button>
                    <button class="layui-btn" lay-filter="add" lay-submit>&emsp;{:dictionary('dictionary.submit')}&emsp;</button>
                </div>
            </form>
        </div>
    </div>
</div>
{include file="public/_footer"}
<script>
    layui.use(['form', 'element'], function () {
        var form = layui.form;
        var $ = layui.jquery;
        form.on('submit(add)', function (data) {
            var arr = data.field;
            // 提交数据
            $.post('{:url("add")}', arr, function (res) {
                if(res.code === 0) {
                    layer.msg(res.msg);
                    setTimeout(function () {
                        window.location.href = "{:url('index')}";//'index.html';
                    },500);
                }else {
                    layer.msg(res.msg);
                }
            },'JSON');
            return false;
        });
    });
</script>
</body>
</html>